import React from 'react';
import { QuickQueryC, SecondHeaderC } from '../../comps';

class QuickQueryDemo extends React.Component {
  constructor(props) {
    super(props);

    this.state = {
      ds: undefined,
      init1: undefined,
      init2: undefined,
    };

    setTimeout(() => {
      this.setState({
        ds: [
          { value: '1', title: '近三个月' },
          { value: '2', title: '近半年' },
        ],
        init1: '2',
        init2: '2',
      });
    }, 3000);
  }
  render() {
    return (
      <div style={{ padding: '20px' }}>
        <SecondHeaderC title='同步' />
        <QuickQueryC
          dataSource={[
            { value: '1', title: '近三个月' },
            { value: '2', title: '近半年' },
            { value: '3', title: '近一年' },
            { value: '4', title: '近三年' },
          ]}
          initialValue='2'
          disabled={['3', '4']}
          onChange={(e) => console.log(e)}
        />
        <br />
        <SecondHeaderC title='异步数据源' />
        <QuickQueryC dataSource={this.state.ds} onChange={(e) => console.log(e)} />
        <br />
        <SecondHeaderC title='异步数据源+异步初始化' />
        <QuickQueryC dataSource={this.state.ds} initialValue={this.state.init1} onChange={(e) => console.log(e)} />
      </div>
    );
  }
}

export default QuickQueryDemo;
